<style>
    .diskType .popover {
        max-width: 400px !important;
    }
</style>

<div class="hbox hbox-auto-xs hbox-auto-sm" ng-init="
    app.settings.asideFolded = false;
    app.settings.asideDock = false;
  ">
    <!-- main -->
    <div class="col">
        <!-- main header -->
        <div class="bg-light lter b-b wrapper-md">
            <div class="row">
                <div class="col-sm-6 col-xs-12">
                    <h1 class="m-n font-thin h3 text-black">日志弹性清理</h1>
                    <small class="text-muted">日志弹性清理详情</small>
                </div>
            </div>
        </div>
        <!-- / main header -->
        <div class="wrapper-md">
            <!-- toaster directive -->
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
            <!-- / toaster directive -->

            <uib-tabset>
                <uib-tab index="0" heading="服务器配置">
                    <div class="panel panel-default" ng-controller="logcleanupCtrl">
                        <div class="panel-body">
                            <form class="form-inline" role="form">


                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon">服务器名称</span>
                                        <input type="text" class="form-control" ng-model="queryName" placeholder="名称">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon">服务器组</span>
                                        <ui-select ng-model="nowServerGroup.selected" theme="bootstrap">
                                            <ui-select-match placeholder="搜索服务器组名称......">{{$select.selected.name}}
                                            </ui-select-match>
                                            <ui-select-choices refresh="queryServerGroup($select.search)"
                                                               refresh-dalay="0"
                                                               repeat="item in serverGroupList | filter: $select.search">
                                                <div ng-bind-html="item.name | highlight: $select.search"></div>
                                            </ui-select-choices>
                                        </ui-select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon">启用状态</span>
                                        <select class="form-control" ng-model="nowEnabled"
                                                ng-options="type.code as type.name for type in enabledType">
                                            <option value="">--请选择--</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <button type="button" class="btn btn-info" ng-click="doQuery()"><span
                                            class="glyphicon glyphicon-search"></span>搜索
                                    </button>
                                    <button type="button" class="btn btn-info" ng-click="reSet()"><span
                                            class="glyphicon glyphicon-repeat"></span>重置
                                    </button>
                                    <button type="button" class="btn btn-success" ng-click="sync()"><span
                                            class="glyphicon glyphicon-refresh"></span>更新数据
                                    </button>
                                </div>
                            </form>

                            <div class="panel panel-default" style="margin-top: 5px;;">
                                <div class="panel-body">
                                    <div>
                                        <table class="table table-hover table-bordered table-striped">
                                            <thead>
                                            <tr>
                                                <td class="col-md-2">服务器</td>
                                                <td class="col-md-2">IP</td>
                                                <td class="col-md-1">环境</td>
                                                <td>启用</td>
                                                <td>归档(天)</td>
                                                <td class="col-md-2">磁盘使用率</td>
                                                <td>详情</td>
                                                <td>操作</td>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr ng-repeat="item in pageData">
                                                <td>
                                                    <b style="color: #286090">{{item.serverName}}-{{item.serialNumber}}</b>
                                                </td>
                                                <td>
                                                    </span>{{item.serverDO.insideIp}}</span>
                                                </td>
                                                <td>
                                                    <b style="color: {{item.env.color}}">{{item.env.name}}</b>
                                                </td>
                                                <td>
                                                    <b class="fa fa-circle-o"
                                                       uib-popover-html="'禁用'" popover-trigger="'mouseenter'"
                                                       style="color: #777" ng-if="item.enabled == 0"></b>
                                                    <b class="fa fa-circle"
                                                       uib-popover-html="'启用'" popover-trigger="'mouseenter'"
                                                       style="color: #449d44" ng-if="item.enabled == 1"></b>
                                                </td>
                                                <td>{{item.history}}</td>
                                                <td>
                                                    <div class="col-md-2">
                                                        <span class="label" ng-show="item.diskType == 'SYS'"
                                                              uib-popover-html="'SYSDISK'" popover-trigger="'mouseenter'"
                                                              style="background-color: #777; color: white;">
                                                            <i class="glyphicon glyphicon-hdd"></i>S</span>
                                                        <span class="label" ng-show="item.diskType == 'DATA'"
                                                              uib-popover-html="'DATADISK'" popover-trigger="'mouseenter'"
                                                              style="background-color: #777; color: white;">
                                                            <i class="glyphicon glyphicon-hdd"></i>D</span>
                                                    </div>
                                                    <div class="col-md-9" style=" margin-left:3px; margin-top:1px;">
                                                        <div class="progress" ng-show="item.freeDiskSpace != -1">
                                                        <span class="progress-bar" role="progressbar"
                                                              uib-popover-html="item.sizeView" popover-trigger="'mouseenter'"
                                                              ng-show="item.freeDiskSpace < 15"
                                                              aria-valuenow="item.diskRate" aria-valuemin="0"
                                                              aria-valuemax="100"
                                                              style="min-width: 2em; background-color: #c9302c; width: {{100 - item.freeDiskSpace}}%;">
                                                            <b>{{100 - item.freeDiskSpace}}%</b>
                                                        </span>
                                                            <span class="progress-bar" role="progressbar"
                                                                  uib-popover-html="item.sizeView" popover-trigger="'mouseenter'"
                                                                  ng-show="item.freeDiskSpace >= 15"
                                                                  aria-valuenow="item.diskRate" aria-valuemin="0"
                                                                  aria-valuemax="100"
                                                                  style="min-width: 2em; background-color: #20a03f; width: {{100 - item.freeDiskSpace}}%;">
                                                            <b>{{100 - item.freeDiskSpace}}%</b>
                                                        </span>
                                                        </div>
                                                    </div>
                                                </td>
                                                <td>
                                                    <span class="label" uib-popover-html="item.updateTime"
                                                           popover-trigger="'mouseenter'"
                                                           style="background-color: #ff8700; color: white;">采样:{{item.updateTimeView}}</span>
                                                    <div ng-show="item.enabled">
                                                        <span class="label" uib-popover-html="item.cleanupTime" ng-show="item.cleanupTime != ''"
                                                              popover-trigger="'mouseenter'"
                                                              style="background-color: #ff5f87; color: white;">清理:{{item.cleanupTimeView}}</span>
                                                    </div>
                                                </td>
                                                <td>
                                                    <button ng-click="edit(item)"
                                                            class="btn btn-xs"
                                                            style="margin-left: 5px; background-color: #2e6da4; color: white;">
                                                        <span class="glyphicon glyphicon-edit"></span>编辑
                                                    </button>

                                                    <button  ng-click="update(item)"
                                                            class="btn btn-xs"
                                                            uib-popover-html="'查询最新磁盘信息'"
                                                            popover-trigger="'mouseenter'"
                                                            style="margin-left: 5px; background-color: limegreen; color: white;">
                                                        <span class="glyphicon glyphicon-repeat"></span>查询
                                                    </button>

                                                    <button ng-click="task(item)"
                                                            ng-show="item.enabled == true"
                                                            class="btn btn-xs pull-right"
                                                            uib-popover-html="'任务详情'" popover-trigger="'mouseenter'"
                                                            style="margin-left: 5px; background-color: limegreen; color: white;">
                                                        <span class="icon icon-list"></span>任务
                                                    </button>
                                                </td>
                                            </tr>
                                            </tbody>
                                            <tfoot>
                                            <tr>
                                                <td colspan="9">
                                                    <ul style="margin: 0px; float: right;" uib-pagination
                                                        total-items="totalItems" ng-model="currentPage"
                                                        items-per-page="pageLength" max-size="10"
                                                        ng-change="pageChanged()" previous-text="&lsaquo;"
                                                        next-text="&rsaquo;"></ul>
                                                </td>
                                            </tr>
                                            </tfoot>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </uib-tab>
            </uib-tabset>
        </div>
    </div>
    <!-- / main -->
</div>

<script type="text/ng-template" id="logcleanupTask">
    <div ng-include="'tpl/modal/logcleanup/logcleanup_task_modal.html'"></div>
</script>

<script type="text/ng-template" id="logcleanupInfo">
    <div ng-include="'tpl/modal/logcleanup/logcleanup_info_modal.html'"></div>
</script>